class duplicate { s: number[]; constructor(s: number[]) { this.s = s; } check() { for (var i: number = 0; i < this.s.length; i++) { for (var j: number = i+1; j <= this.s.length; j++) { if (this.s[i] == this.s[j]) this.s.splice(j, 1); } } } display() { console.log("arrays without duplicate elements"); for (var i: number = 0; i < this.s.length; i++) { console.log(this.s[i]); } } } var d = new duplicate([11, 12, 12, 13, 13, 13, 14, 14, 12, 15]); var p = new duplicate([11,12,12,12,13,13,13]); d.check(); d.display(); p.check(); p.display();